#include <iostream>
#include <numeric>
#include <iterator>
#include <valarray>
using namespace std;

// void f(valarray<int>& a)
// {
//     // slice_array<int>& v_even = a[slice(0, a.size()/2, 2)];
// }

int main()
{
    valarray<int> a(9);
    iota(begin(a), end(a), 0);
    // 流迭代器是一种类型
    copy(begin(a), end(a), ostream_iterator<int>{cout, "\t"});
    cout << "\n";
    // slice_array实现细节仅仅含一个指针
    slice_array<int> v_even = a[slice(0, a.size() / 2 + a.size()%2, 2)];
    v_even = 2;
    // f(a);
    a[slice{1, a.size()/2, 2}] = 3;
    adjacent_difference(begin(a), end(a), begin(a));
    copy(begin(a), end(a), ostream_iterator<int>{cout, "\t"});
    cout << "\n";

    return 0;
}